package f.f0.l;

import java.security.cert.CertificateParsingException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLSession;

/* compiled from: OkHostnameVerifier */
public final class d implements HostnameVerifier {
    public static final d a = new d();

    public static List<String> a(X509Certificate x509Certificate) {
        List b = b(x509Certificate, 7);
        List b2 = b(x509Certificate, 2);
        ArrayList arrayList = new ArrayList(b2.size() + b.size());
        arrayList.addAll(b);
        arrayList.addAll(b2);
        return arrayList;
    }

    public static List<String> b(X509Certificate x509Certificate, int i) {
        ArrayList arrayList = new ArrayList();
        try {
            Collection<List> subjectAlternativeNames = x509Certificate.getSubjectAlternativeNames();
            if (subjectAlternativeNames == null) {
                return Collections.emptyList();
            }
            for (List list : subjectAlternativeNames) {
                if (list != null) {
                    if (list.size() >= 2) {
                        Integer num = (Integer) list.get(0);
                        if (num != null) {
                            if (num.intValue() == i) {
                                String str = (String) list.get(1);
                                if (str != null) {
                                    arrayList.add(str);
                                }
                            }
                        }
                    }
                }
            }
            return arrayList;
        } catch (CertificateParsingException unused) {
            return Collections.emptyList();
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:55:0x00ff A:{SYNTHETIC} */
    public boolean c(java.lang.String r10, java.security.cert.X509Certificate r11) {
        /*
        r9 = this;
        r0 = f.f0.c.r;
        r0 = r0.matcher(r10);
        r0 = r0.matches();
        r1 = 0;
        r2 = 1;
        if (r0 == 0) goto L_0x002b;
    L_0x000e:
        r0 = 7;
        r11 = b(r11, r0);
        r0 = r11.size();
        r3 = 0;
    L_0x0018:
        if (r3 >= r0) goto L_0x0100;
    L_0x001a:
        r4 = r11.get(r3);
        r4 = (java.lang.String) r4;
        r4 = r10.equalsIgnoreCase(r4);
        if (r4 == 0) goto L_0x0028;
    L_0x0026:
        goto L_0x00ff;
    L_0x0028:
        r3 = r3 + 1;
        goto L_0x0018;
    L_0x002b:
        r0 = java.util.Locale.US;
        r10 = r10.toLowerCase(r0);
        r0 = 2;
        r11 = b(r11, r0);
        r11 = r11.iterator();
    L_0x003a:
        r0 = r11.hasNext();
        if (r0 == 0) goto L_0x0100;
    L_0x0040:
        r0 = r11.next();
        r0 = (java.lang.String) r0;
        if (r10 == 0) goto L_0x00fc;
    L_0x0048:
        r3 = r10.length();
        if (r3 == 0) goto L_0x00fc;
    L_0x004e:
        r3 = ".";
        r4 = r10.startsWith(r3);
        if (r4 != 0) goto L_0x00fc;
    L_0x0056:
        r4 = "..";
        r5 = r10.endsWith(r4);
        if (r5 == 0) goto L_0x0060;
    L_0x005e:
        goto L_0x00fc;
    L_0x0060:
        if (r0 == 0) goto L_0x00fc;
    L_0x0062:
        r5 = r0.length();
        if (r5 == 0) goto L_0x00fc;
    L_0x0068:
        r5 = r0.startsWith(r3);
        if (r5 != 0) goto L_0x00fc;
    L_0x006e:
        r4 = r0.endsWith(r4);
        if (r4 == 0) goto L_0x0076;
    L_0x0074:
        goto L_0x00fc;
    L_0x0076:
        r4 = r10.endsWith(r3);
        r5 = 46;
        if (r4 != 0) goto L_0x008e;
    L_0x007e:
        r4 = new java.lang.StringBuilder;
        r4.<init>();
        r4.append(r10);
        r4.append(r5);
        r4 = r4.toString();
        goto L_0x008f;
    L_0x008e:
        r4 = r10;
    L_0x008f:
        r3 = r0.endsWith(r3);
        if (r3 != 0) goto L_0x00a4;
    L_0x0095:
        r3 = new java.lang.StringBuilder;
        r3.<init>();
        r3.append(r0);
        r3.append(r5);
        r0 = r3.toString();
    L_0x00a4:
        r3 = java.util.Locale.US;
        r0 = r0.toLowerCase(r3);
        r3 = "*";
        r3 = r0.contains(r3);
        if (r3 != 0) goto L_0x00b7;
    L_0x00b2:
        r0 = r4.equals(r0);
        goto L_0x00fd;
    L_0x00b7:
        r3 = "*.";
        r6 = r0.startsWith(r3);
        if (r6 == 0) goto L_0x00fc;
    L_0x00bf:
        r6 = 42;
        r6 = r0.indexOf(r6, r2);
        r7 = -1;
        if (r6 == r7) goto L_0x00c9;
    L_0x00c8:
        goto L_0x00fc;
    L_0x00c9:
        r6 = r4.length();
        r8 = r0.length();
        if (r6 >= r8) goto L_0x00d4;
    L_0x00d3:
        goto L_0x00fc;
    L_0x00d4:
        r3 = r3.equals(r0);
        if (r3 == 0) goto L_0x00db;
    L_0x00da:
        goto L_0x00fc;
    L_0x00db:
        r0 = r0.substring(r2);
        r3 = r4.endsWith(r0);
        if (r3 != 0) goto L_0x00e6;
    L_0x00e5:
        goto L_0x00fc;
    L_0x00e6:
        r3 = r4.length();
        r0 = r0.length();
        r3 = r3 - r0;
        if (r3 <= 0) goto L_0x00fa;
    L_0x00f1:
        r3 = r3 + -1;
        r0 = r4.lastIndexOf(r5, r3);
        if (r0 == r7) goto L_0x00fa;
    L_0x00f9:
        goto L_0x00fc;
    L_0x00fa:
        r0 = 1;
        goto L_0x00fd;
    L_0x00fc:
        r0 = 0;
    L_0x00fd:
        if (r0 == 0) goto L_0x003a;
    L_0x00ff:
        r1 = 1;
    L_0x0100:
        return r1;
        */
        throw new UnsupportedOperationException("Method not decompiled: f.f0.l.d.c(java.lang.String, java.security.cert.X509Certificate):boolean");
    }

    public boolean verify(String str, SSLSession sSLSession) {
        try {
            return c(str, (X509Certificate) sSLSession.getPeerCertificates()[0]);
        } catch (SSLException unused) {
            return false;
        }
    }
}
